from PyQt6.QtCore import QRectF
from PyQt6.QtWidgets import QTextBrowser

from gui.utils.size import WORLD_SIZE, RESOURCE_HEIGHT, ZONING_SIZE, MSG_WIDTH, MSG_HEIGHT, FILTER_HEIGHT, TOOL_WIDTH
from utils.event_bus import EventBus


class PanelInformation(QTextBrowser):
    def __init__(self, parent=None):
        super().__init__(parent)
        rect = QRectF(WORLD_SIZE, RESOURCE_HEIGHT + ZONING_SIZE + FILTER_HEIGHT, MSG_WIDTH - TOOL_WIDTH, MSG_HEIGHT / 2)
        self.setGeometry(rect.toRect())

        EventBus.register('update_info', self.update_info)

    def update_info(self, msg: str):
        self.clear()
        self.setText(msg)
